Web sites and applications are vulnerable to attack by malicious third parties. In one class of attacks, often referred to as “Man-in-the-Browser” (MitB) or “Web Injection” attacks, malware in a compromised web browser injects malicious code into a web page downloaded by the browser. Such injected malicious code can alter the content of a web page. By way of example, injected code can introduce form fields into a web page that can be used by a malicious third party to steal sensitive information (e.g., user credentials, passwords, social security numbers, etc.). Some technologies, e.g., Web Tripwire and Zarathustra, have been developed to detect injected code, but many of these solutions are easily disabled by malicious third parties and can only detect, not prevent, MitB attacks.